import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:liuxlcommon/lget/lget.dart';
import 'package:liuxlcommon/view/lxl_widget.dart';
import 'package:liuxlcommon/view/my_style.dart';
import 'package:love_newf/app/com/base/base_state.dart';
import 'package:love_newf/value/app_lstyle.dart';

import 'open_live_setting_logic.dart';

class OpenLiveSettingPage extends StatefulWidget {
  const OpenLiveSettingPage({Key? key}) : super(key: key);

  @override
  State<OpenLiveSettingPage> createState() => _OpenLiveSettingPageState();
}

class _OpenLiveSettingPageState
    extends BaseState<OpenLiveSettingPage, OpenLiveSettingLogic> {
  @override
  get initData {
    title = "开播";
    logic.getData();
  }

  @override
  Widget get easyBody => LColumn.eazy([
        LColumn.eazy([
          LColumn.eazy([
            LText.easy("房间类型", 16.w),
            10.lsh,
            LRow.eazy([
              for (int i = 0; i < logic.roomNumberTypes.length; i++)
                LText.easy(
                        logic.roomNumberTypes[i],
                        15.w,
                        null,
                        logic.roomNumberTypeIndex == i
                            ? Colors.white
                            : Colors.black)
                    .radius(12.w)
                    .onTapL(() {
                      logic.roomNumberTypeIndex = i;
                      logic.update();
                    })
                    .margin(right: 10.w, bottom: 10.w)
                    .gradient(
                        logic.roomNumberTypeIndex == i
                            ? const [Color(0xFFFD7AC4), Color(0xFFFE622F)]
                            : const [Color(0xFFf2f2f2), Color(0xFFf2f2f2)],
                        Alignment.centerRight)
                    .padding(left: 15.w, top: 8.w, right: 15.w, bottom: 8.w)
            ]),
          ])
              .align(Alignment.topLeft)
              .radius(12.w)
              .bgColor(Colors.white)
              .paddingAll(12.w),
          12.lsh,
          LColumn.eazy([
            LText.easy("麦位模式", 16.w),
            10.lsh,
            LRow.eazy(List.generate(
                logic.roomMap[logic.roomNumberTypeIndex]!.length, (i) {
              var item = logic.roomMap[logic.roomNumberTypeIndex]![i];
              return LText.easy(
                      item.name,
                      15.w,
                      null,
                      logic.selectRoomTypeIndex == i
                          ? Colors.white
                          : Colors.black)
                  .radius(12.w)
                  .onTapL(() {
                    logic.selectRoomTypeIndex = i;
                    logic.update();
                  })
                  .margin(right: 10.w, bottom: 10.w)
                  .gradient(
                      logic.selectRoomTypeIndex == i
                          ? const [Color(0xFFFD7AC4), Color(0xFFFE622F)]
                          : const [Color(0xFFf2f2f2), Color(0xFFf2f2f2)],
                      Alignment.centerRight)
                  .padding(left: 15.w, top: 8.w, right: 15.w, bottom: 8.w);
            })),
          ])
              .align(Alignment.topLeft)
              .radius(12.w)
              .bgColor(Colors.white)
              .paddingAll(12.w),
          12.lsh,
          LColumn.eazy([
            LRow.eazy([
              LText.easy("房间欢迎语", 15.w, null, Colors.white).flex(1),
              const Icon(Icons.edit_calendar, color: Colors.white)
            ]),
            LInput(
              logic.firstMsg,
              lStyle: LStyle(
                  hintText: "请输入房间欢迎语",
                  padding: EdgeInsets.only(top: 10.w),
                  color: Colors.white),
            )
                .onChange((text) => logic.firstMsg = text)
                .size(double.infinity, 100.w)
          ])
              .align(Alignment.topLeft)
              .radius(12.w)
              .bgColor(Colors.black54)
              .paddingAll(12.w),
        ]).flex(1).scroll(isScroll: true),
        LRow.eazy([
          // LText("美颜").style(btn2Sty).flex(1),
          // 12.lsw,
          LText("创建房间").style(rzBtnSty).flex(1).onTapL(() => logic.createLive())
        ]),
        LSizeH(LGet.bottomPadding(context))
      ]).onTapDown((de) => OldLInput.unfocus()).paddingAll(12.w);
}
